package ${table.serviceImplClassPackage};

import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import ${table.serviceClassPackage}.${table.beanName}Service;
import ${table.mapperClassPackage}.${table.beanName}Mapper;
<#if table.isGeneratorSelect>
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
</#if>
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import ${table.entityClassPackage}.${table.beanName};
/**
* @author：${table.author}
* @since：${table.date}
* @remark：${table.comment}服务层实现类
*/
@Service
public class ${table.generatorName} extends ServiceImpl<${table.beanName}Mapper,${table.beanName}> implements ${table.beanName}Service  {
        @Autowired
        private ${table.beanName}Mapper ${table.somallbeanName}Mapper;
        <#if table.isGeneratorSelect>
        @Override
        public IPage<${table.beanName}> listByPage<#if table.selectCustomWay?has_content>${table.selectCustomWay}</#if>(${table.beanName}  ${table.somallbeanName}) {
                IPage<${table.beanName}> iPage = new Page<>(${table.somallbeanName}.getNum(), ${table.somallbeanName}.getSize());
                QueryWrapper<${table.beanName}> wrapper = new QueryWrapper<>();
                <#if table.isSelectCustom>
                <#if table.selectCustomConditionList?size != 0>
                <#list table.selectCustomConditionList as custom>
                        <#assign firstChar = custom.columnBean?substring(0, 1)>
                        <#assign remainingChars = custom.columnBean?substring(1)>
                        if(${table.somallbeanName}.get${firstChar?capitalize}${remainingChars}() != null &&!"".equals(${table.somallbeanName}.get${firstChar?capitalize}${remainingChars}())){
                        wrapper.${custom.condition}("${custom.column}",${table.somallbeanName}.get${firstChar?capitalize}${remainingChars}());
                        }
                </#list>
                </#if>
                <#if table.orderBy.columnsDESC?size != 0>
                        wrapper.orderByDesc(<#list table.orderBy.columnsDESC as customDESC><#if customDESC?is_last>"${customDESC}"<#else>"${customDESC}",</#if></#list>)</#if>
                <#if table.orderBy.columnsASC?size != 0>
                        wrapper.orderByDesc(<#list table.orderBy.columnsASC as customASC><#if customASC?is_last>"${customASC}"<#else>"${customASC}",</#if></#list>)</#if>
                ;
        </#if>
                return ${table.somallbeanName}Mapper.selectPage(iPage, wrapper);
        }
        </#if>
        <#if table.isGeneratorSave>
        @Override
        public boolean save(${table.beanName}  ${table.somallbeanName}) {
                if(${table.somallbeanName}Mapper.insert(${table.somallbeanName})==1){
                        return true;
                }
                return false;
        }
        </#if>
        <#if table.isGeneratorUpdate>
        @Override
        public boolean updateById(${table.beanName}  ${table.somallbeanName}) {
                if(${table.somallbeanName}Mapper.updateById(${table.somallbeanName})==1){
                        return true;
                }
                return false;
        }
        </#if>
        <#if table.isGeneratorDelete>
        @Override
        public boolean deleteById(String id) {
                if(${table.somallbeanName}Mapper.deleteById(id)==1){
                        return true;
                }
                return false;
        }
        </#if>
}

